//
// Created by ole on 24-8-27.
//

#include "HotPlugin.h"

struct HotPluginReceiver final : MessageReceiver {
    void onReceived(const std::shared_ptr<Message> &intent) override {
        Log::d("HotPluginReceiver", "onReceived() : '" + intent->toString() + "'");
    }
};

const auto topic = std::make_shared<Topic>("/core/plugin/TimerPlugin/onTime");
const auto receiver = std::make_shared<HotPluginReceiver>();

bool HotPlugin::onStart() {
    Log::d(TAG, "onStart");
    subscribe(topic, receiver);
    return true;
}

bool HotPlugin::onStop() {
    Log::d(TAG, "onStop");
    unsubscribe(topic, receiver);
    return true;
}

extern "C" BasePlugin *createInstance() {
    return new HotPlugin();
}

extern "C" void destroyInstance(const BasePlugin *instance) {
    delete instance;
}